#ifndef __IF_SOC_ADC_H__
#define __IF_SOC_ADC_H__

#include <functional>
#include <stdint.h>
#include "soc/iperipheral.h"
#include "soc/soc_comm_def.h"

#define SOC_ADC_SAMPLE_COUNT_MAX 500

class IF_SOC_Adc : public IPeripheralEx<IF_SOC_Adc, SOC_ADC_MAX>
{
public:
    using ADC_CONVERT_OVER_IRQ_FUNC = std::function<void(IF_SOC_Adc &sender, int ch, int val)>;

public:
    //校准
    virtual void Calib() = 0;
    
    //在要求告诉的时候，通过时序方式，读取
    virtual void StartAdcAsync() = 0;
    virtual int GetValueAsync() = 0;

    //单通道阻塞读取 [轮询模式]
    virtual int GetValue(int ch) = 0;
    virtual void StartAllAdcPoll(uint16_t *buffer, int size) = 0;
    //
    virtual void StopAdc() = 0;

    virtual void StartAdc_IT(int ch) = 0;
    virtual void StopAdc_IT() = 0;

    virtual void StartAdc_DMA(int chCount) = 0;
    virtual void StartAdc_DMA_NS(int chCount, int sampleCount) = 0;
    virtual void StopAdc_DMA() = 0;
    virtual int GetDMAValue(int index) = 0;
    virtual uint16_t *GetDMABuffer() = 0;
    
    virtual void SetAdcConvertOverCallBack(const ADC_CONVERT_OVER_IRQ_FUNC &&func) = 0;
    virtual void Raise_ConvertOver_IRQ() = 0;
};

#endif // __IF_SOC_ADC_H__
